<template>
	<div v-show="visible" class="alert-mask">
		<div class="alert">
			<div class="alert-text">
				<slot />
			</div>
			<div class="footer-btn">
				<div class="btn" @click="leftHandle">{{ leftBtn }}</div>
				<div class="btn" @click="rightHandle">{{ rightBtn }}</div>
			</div>
		</div>
	</div>
</template>
<script>
export default {
	name: "MyAlert",
	props: {
		text: {
			type: String,
			default: "这是一个Alert",
		},
		value: {
			type: Boolean,
			default: false,
		},
		leftBtn: {
			type: String,
			default: "取消",
		},
		rightBtn: {
			type: String,
			default: "确定",
		},
	},
	data() {
		return {
			visible: false,
		};
	},
	watch: {
		value(val) {
			this.visible = val;
			this.$emit(val ? "on-show" : "on-hide");
		},
		visible(val) {
			this.$emit("input", val);
		},
	},
	methods: {
		leftHandle() {
			this.visible = false;
			this.$emit("on-left-click");
		},
		rightHandle() {
			this.visible = false;
			this.$emit("on-right-click");
		},
	},
};
</script>
<style scoped>
body {
	width: 100%;
	height: 100%;
}
.alert-mask {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: rgba(55, 55, 55, 0.6);
	z-index: 100;
}
.tip {
	text-align: center;
	margin-bottom: 5px;
	font-size: 12px;
}
.title {
	font-size: 14px;
	font-weight: 600;
}
.pbody {
	color: #999;
}
.pfoot {
	color: #555;
}
.alert {
	position: fixed;
	top: 45%;
	left: 50%;
	width: 60%;
	background: white;
	border-radius: 10px;
	transform: translate(-50%, -50%);
}
.alert-text {
	margin-top: 10px;
	font-size: 14px;
	/* height: 80px; */
	min-height: 80px;
	/* min-height: 70px; */
	/* text-align: center; */
	width: 100%;
	padding: 10px;
	border-bottom: 1px solid #ccc;
	line-height: 20px;
	overflow: hidden;
	vertical-align: middle;
	display: flex;
	justify-content: center;
	align-items: center;
}
/* .alert-text div{
    position: relative;
    top:50%;
    left:50%;
    max-height: 50px;
    transform: translate(-50%,-50%);
    text-align: center;
    overflow: hidden;
} */
.footer-btn {
	width: 100%;
	height: 35px;
}
.btn {
	float: left;
	width: 49%;
	height: 100%;
	border-right: 1px solid #ccc;
	text-align: center;
	line-height: 35px;
	color: #3385ff;
	/* font-weight:500; */
	font-size: 18px;
}
.btn:last-child {
	border: none;
}
</style>
